﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace Dqaqs.Data
{
	[MetadataType(typeof(DataSourceMetadata))]
	public partial class DataSource
	{
		[DataMember]
		public string ProjectName
		{
			get
			{
				if (Project != null)
					return Project.Title;
				return String.Empty;
			}
			set
			{
			}
		}

		[DataMember]
		public Schema SchemaDefinition
		{
			get { return Data.Schema.Parse(Schema); }
			set { Schema = value != null ? value.ToString() : string.Empty; }
		}
	}

	public class DataSourceMetadata
	{
		[Required]
		[DisplayName("Database Title")]
		public string Title { get; set; }

		[Required]
		public Guid ProjectId { get; set; }

		[Required]
		[DisplayName("Supported Schema")]
		public string Schema { get; set; }
	}
}
